/**
 * author:Administrator
 * date:2016/3/25
 * desc:TODO
 */
'use strict';

class VendorShopDetail {
  constructor(data) {
    this.parse(data);
    Object.freeze(this);
  }

  parse(data) {
    if (!data || !Array.isArray(data) || data.length == 0) return;

    let item0 = data[0];
    this.id = item0.id;
    this.ver = item0.ver;
    this.vendorId = item0.vendorId;
    this.categoryId = item0.categoryId;
    this.maxCount = item0.maxCount;
    this.remain = item0.remain;
    this.name = item0.name;
    this.price = item0.price;
    this.imgUrls = item0.imgUrls;
    this.desc = item0.desc;
    this.createdAt = item0.createdAt;
    this.updatedAt = item0.updatedAt;

    this.shopList = data.map(item => {
      return {
        id: item.shopId,
        name: item.shopName,
        locName: item.locName
      }
    });
  }
}

module.exports = VendorShopDetail;